#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QTimer>
#include <QFile>
#include "RSA/rsa.h"
extern "C" {
#include "SHA256/sha256.h"
}


QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    void on_btnOpenCom_clicked(bool checked);

    void on_btnOpenFile_clicked(bool checked);

    void on_btnDownLoad_clicked(bool checked);

    void serialPortReadyRead();

    void serialTimerTimeoutHandle( );
private:
    Ui::MainWindow *ui;
    QSerialPort *serialPort;
    QString updateBinFilePath=NULL;
    QTimer *serialTimer;
    QTimer *sendDataTimer;
    void serialPortInit();
    QByteArray serialPortReadArry;
    QString updateFilePath;
    qint64 bytesRemaining;
    qint64 bytesFileSize;

    QFile *sendFile;

    SHA256_CTX ctx;

	key_t pub = { 0 };
	key_t priv = { 0 };

    bool isPrintableAscii(const QByteArray &data);

};
#endif // MAINWINDOW_H
